

package com.hazelcast.azure;

import java.util.Objects;

/**
 * Structure that represents the discovery output information. It is used to store public and private IP Addresses that
 * is returned from Azure API.
 */
final class AzureAddress {
    private final String privateAddress;
    private final String publicAddress;

    AzureAddress(String privateAddress, String publicAddress) {
        this.privateAddress = privateAddress;
        this.publicAddress = publicAddress;
    }

    String getPrivateAddress() {
        return privateAddress;
    }

    String getPublicAddress() {
        return publicAddress;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        AzureAddress that = (AzureAddress) o;

        if (!Objects.equals(privateAddress, that.privateAddress)) {
            return false;
        }
        return Objects.equals(publicAddress, that.publicAddress);
    }

    @Override
    public int hashCode() {
        int result = privateAddress != null ? privateAddress.hashCode() : 0;
        result = 31 * result + (publicAddress != null ? publicAddress.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "AzureAddress{" + "privateAddress='" + privateAddress + '\'' + ", publicAddress='" + publicAddress + '\'' + '}';
    }
}
